package com.wise.service.portal.content.articlecommons;

import com.wise.entities.content.Article;
import com.wise.entities.content.ArticleStatus;
import com.wise.framework.dao.SqlSelect;
import com.wise.framework.daomodel.DaoPageList;
import com.wise.framework.restful.PageResultList;
import com.wise.summer.v1.portal.content.articlecommons.ListArticleCommons;
import com.wise.summer.v1.portal.content.webarticles.ListWebArticles;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

@Service
@SummerService
public class ListArticleCommonsService implements SummerServiceBean<ListArticleCommons> {
	@Override
	public void sum(ListArticleCommons model) {
		SqlSelect sql = SqlSelect.selec("*")
				.fromClassName(Article.class)
//				.eq(StringUtils.isNotBlank(model.getColumnId()), Article._columnId, model.getColumnId())
				.eq(Article._state, ArticleStatus.PUBLISH.value())
				.eqLang(Article._lang)
				.order_by(Article._sort)
				.order_by(Article._publishTime + " desc");

		PageResultList<ListArticleCommons.Result> articleList = DaoPageList.s(ListArticleCommons.Result.class, sql, model.getStart(), model.getLimit());
		model.setSummerResult(articleList);
	}
}
